package com.cj.common.utils;

import org.dom4j.Element;

public class TreeUtil {

	public static Element getElement(Element root,Object obj,String textPropertyName,String valuePropertyName){
		String text = ReflectionUtils.getFieldValue(obj, textPropertyName).toString();
		String value = ReflectionUtils.getFieldValue(obj, valuePropertyName).toString();
		Element element = root.addElement("TreeNode").addAttribute(
				"text", text)
				.addAttribute(
				"value",
				ReflectionUtils.getFieldValue(obj, valuePropertyName)
						.toString()
						+ ";" + text)
				.addAttribute("checked",
				"false"); // 开始是否被选择
			element.addAttribute("action",
					"javascript:try{showDetail('" + value + "','" +text
							+ "');}catch(err){};");
			return element;
	}
}
